$(function(){
	var path="";
	$.ajax({
		"url" : path + "class/class",
		"type" : "get",
		"data" : "",
		"dataType" : "json",
		"success" : function(data) {
			for ( var i = 0; i < data.length; i++) {
				$option = $("<option value='"+data[i].id+"'>"+data[i].name+"</option>");
				$("#classSel").append($option);
			}
		}
	});
	
	$("#save").click(function(){
		var urlParam = $("form").serialize();
		var classSel = $("#classSel").val();
		$.ajax({
			"url" : path + "student/save",
			"type" : "post",
			"data" : urlParam+"&classSel="+classSel,
			"dataType" : "text",
			"success" : function(data) {
				if(data=="true"){
					alert("新增成功");
					location.href="http://localhost:8080/StudentInfo/";
					//back();
				}else{
					alert("新增失败");
				}
			}
		});
	});
	
	$("#back").click(function(){
		window.history.go(-1);
	});

});
function back(){
	window.history.go(-1);
}
